import 'package:flutter/material.dart';
import 'package:english_words/english_words.dart';
import 'package:dio/dio.dart';


class Grid extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      body: new Center(
//        child: GridView(
////            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
////                crossAxisCount: 4,
////                childAspectRatio: 2
////            ),
////          children: <Widget>[
////            Icon(Icons.ac_unit),
////            Icon(Icons.airport_shuttle),
////            Icon(Icons.all_inclusive),
////            Icon(Icons.beach_access),
////            Icon(Icons.cake),
////            Icon(Icons.free_breakfast),
////          ],
////        )
      child: CustomScrollView(
        slivers: <Widget>[
//           包含一个导航栏
          SliverAppBar(
            pinned: true,
            expandedHeight: 250,
            flexibleSpace: FlexibleSpaceBar(
              title: const Text('童年智造'),
              background: Image.asset(
                  'images/banner.jpg',
                fit: BoxFit.cover,
              ),
            ),
          ),
          SliverPadding(
            padding: const EdgeInsets.all(8),
            sliver: new SliverGrid(
               delegate: new SliverChildBuilderDelegate((BuildContext context, int index){
                 return new Container(
                   alignment: Alignment.center,
                   color: Colors.cyan[100 * (index % 9)],
                   child: new Text('grid item $index'),
                 );
               })  ,
                gridDelegate:  new SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 2, //Grid 按两列显示
                    mainAxisSpacing: 10,
                    crossAxisSpacing: 10,
                  childAspectRatio: 4
                )),
          ),
          new SliverFixedExtentList(
              delegate: new SliverChildBuilderDelegate(
                  (BuildContext context, int index){
                    return new Container(
                      alignment: Alignment.center,
                      color: Colors.lightBlue[100*(index%9)],
                      child: new Text('list item  $index'),
                    );
                  }
              ),
              itemExtent: 50
          )
        ],
      ),
      ),
    );
  }
}


